home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1066 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.8 KB

  1. Path: service-2.agate.net!usenet
  2. From: andle@biode.com (Jeffrey C. Andle)
  3. Newsgroups: comp.lang.c++
  4. Subject: Complex class appears to be completely missing in VC4.0?
  5. Date: 9 Jan 1996 02:38:01 GMT
  6. Organization: Biode, Inc.
  7. Message-ID: <4cske9$64m@service-2.agate.net>
  8. NNTP-Posting-Host: biode.sdi.agate.net
  9. Mime-Version: 1.0
  10. X-Newsreader: WinVN 0.93.11
  11.  
  12. All right, the BS I've seen with Complex classes in early Borland 
  13. and MS compilers is one thing (functions defined but not implemented,
  14. etc.), but it appears to be completely gone from VC 4.0.
  15.  
  16. I own Watcom 10.0 and 10.5beta, but can't seen to get their library
  17. & header to run with VC.  Is there a "standard" C++ complex class
  18. that is generally available or do I buy the CRC math handbook & wing
  19. it with Taylor series for the trig & pow() functions, etc?
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26. As a side question, when should a function / operator be:
  27.  
  28. ..... Complex &   operator foo ()
  29.  
  30.  
  31. vs.
  32.  
  33.  
  34. ..... Complex     operator foo ()
  35.  
  36. ?
  37.  
  38.  
  39.  
  40.  
  41. the former bombed when I wrote:
  42.  
  43. // Unary - as friend:
  44. Complex&   operator- (Complex& Z);
  45.  
  46. // Binary - as member:
  47. Complex&   Complex::operator- (Complex& Z);
  48.  
  49. // e to a complex number using dexp, sin, cos:
  50. Complex&   Exp(Complex &Z);
  51.  
  52. // division by a long as a member function:
  53. Complex&   Complex::operator/ (double r);
  54.  
  55. then used this function:
  56.  
  57. Complex&   Sinh(Complex &Z)
  58. {
  59.     return ((Exp(Z) - Exp(-Z))/2.);
  60. };
  61.  
  62.  
  63. tracing through the code, each step worked except the binary -,
  64. which apparently subtracted an address from a complex!  Bug or coding
  65. error?
  66.  
  67. Of course, the second approach gave me a slew of "nonstandard extension:
  68. initializing" warnings when assigning:
  69.  
  70. Complex Exp(Complex Y);
  71. Complex Y = Complex(1., 0.);
  72.  
  73. Complex Z = Exp(Y);        // warning!
  74.  
  75. any help at all would be appreciated.
  76. please e-mail to andle@agate.net  (ignore biode.com, as the server is
  77. having molten silicon problems...  (;-<<<)
  78.  
  79.